home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Software für Mac-OS X / Entwickler-Tools / netbeans / modules / ext / djava.jar / koala / dynamicjava / classinfo / TreeMethodInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-14  |  3.0 KB  |  79 lines

  1. package koala.dynamicjava.classinfo;
  2.  
  3. import java.util.Iterator;
  4. import java.util.List;
  5. import koala.dynamicjava.tree.FormalParameter;
  6. import koala.dynamicjava.tree.MethodDeclaration;
  7.  
  8. public class TreeMethodInfo implements MethodInfo {
  9.    private MethodDeclaration methodTree;
  10.    private ClassFinder classFinder;
  11.    private ClassInfo[] parameters;
  12.    private ClassInfo[] exceptions;
  13.    private ClassInfo declaringClass;
  14.    private TypeVisitor typeVisitor;
  15.  
  16.    public MethodDeclaration getMethodDeclaration() {
  17.       return this.methodTree;
  18.    }
  19.  
  20.    public int getModifiers() {
  21.       return this.methodTree.getAccessFlags();
  22.    }
  23.  
  24.    public ClassInfo getReturnType() {
  25.       return (ClassInfo)this.methodTree.getReturnType().acceptVisitor(this.typeVisitor);
  26.    }
  27.  
  28.    public String getName() {
  29.       return this.methodTree.getName();
  30.    }
  31.  
  32.    public ClassInfo[] getParameterTypes() {
  33.       if (this.parameters == null) {
  34.          List var1 = this.methodTree.getParameters();
  35.          Iterator var2 = var1.iterator();
  36.          this.parameters = new ClassInfo[var1.size()];
  37.  
  38.          FormalParameter var4;
  39.          for(int var3 = 0; var2.hasNext(); this.parameters[var3++] = (ClassInfo)var4.getType().acceptVisitor(this.typeVisitor)) {
  40.             var4 = (FormalParameter)var2.next();
  41.          }
  42.       }
  43.  
  44.       return (ClassInfo[])this.parameters.clone();
  45.    }
  46.  
  47.    public ClassInfo[] getExceptionTypes() {
  48.       if (this.exceptions == null) {
  49.          List var1 = this.methodTree.getExceptions();
  50.          Iterator var2 = var1.iterator();
  51.          this.exceptions = new ClassInfo[var1.size()];
  52.  
  53.          for(int var3 = 0; var2.hasNext(); this.exceptions[var3++] = this.lookupClass((String)var2.next(), this.declaringClass)) {
  54.          }
  55.       }
  56.  
  57.       return (ClassInfo[])this.exceptions.clone();
  58.    }
  59.  
  60.    public boolean equals(Object var1) {
  61.       return var1 != null && var1 instanceof TreeMethodInfo ? this.methodTree.equals(((TreeMethodInfo)var1).methodTree) : false;
  62.    }
  63.  
  64.    protected ClassInfo lookupClass(String var1, ClassInfo var2) {
  65.       try {
  66.          return var2 == null ? this.classFinder.lookupClass(var1, var2) : this.classFinder.lookupClass(var1);
  67.       } catch (ClassNotFoundException var4) {
  68.          throw new NoClassDefFoundError(var4.getMessage());
  69.       }
  70.    }
  71.  
  72.    public TreeMethodInfo(MethodDeclaration var1, ClassFinder var2, ClassInfo var3) {
  73.       this.methodTree = var1;
  74.       this.classFinder = var2;
  75.       this.declaringClass = var3;
  76.       this.typeVisitor = new TypeVisitor(this.classFinder, this.declaringClass);
  77.    }
  78. }
  79.